package com.cb.config;

import org.springframework.context.annotation.Configuration;

import java.io.FileWriter;
import java.io.IOException;

@Configuration
public class AlipayConfig {

    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号,开发时使用沙箱提供的APPID，生产环境改成自己的APPID
    public static String APP_ID = "2016110200787476";

    // 商户私钥，您的PKCS8格式RSA2私钥
    public static String APP_PRIVATE_KEY = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCjZz+c7tap/SgyDkBEKwbF7/YF0umC8AbmFBuBqIFMeot9mp2ik2rM4ZLlgspDudIEoz2tPyKLFGYG1od9Jk6xH1t1k0KXi0RmUNOKZpw6LUKzckiTSPD2jBDcTkq05DUPnGBh1+dg1pENNJ6Hl+7HZEITtnougviWx4MurozXiiFBFV4zGoZe/xtD0TQLDp7OGiAE1JmlvABwAF+S6UwUtYoi8JGJIBTz4AwWybJivBuIvskvddXGF4+68FR0JO23mnbbGKuyTPDCWdLhHDjbaKYhQ1z3wCyodWfEK8UvztNYgwJV51Wf0RF137XTIUhCIzXj8E0HIu5A0i5fSgbbAgMBAAECggEAOl+EBhf8b7WUSm103+VPAh77EJGMAc6laEP+n48Gwb91XWWCsrVfDdn3lC3o+9DCCg4W1nEbcfvThtXUiQzKR9Qf5By7SU/jG3n8WBDX9qB8l4ZYDuWbzzeyPkFpxr1Ph0gh1lI+wgVkxAbsKxxHnMtgH5KsizkWfSbA4khQ4B5SKPbJdjUfxtpdVBfYXELJnk/r3gwowOWY0Wciv/Ud8cyAmbheZwebskTPURIEtDAhtokFwJ7qmUDoWOMNxv5QIlYQn+zybb8xc1/ESRMRnx3//M4YSgKtHIHY3fUTDnMeYluzaMqzsj48EigNJOIirfLjt2FqbRVvxREe3ebMoQKBgQDNwbH1PSFSLPfyGswsD1zX97tYNZDDCuUKGVqfd60GUQEdIyq03B4fRwDgPq07Svz2mKgerdCmvIwzhBl1BRQmpiWeOb0i0uQQ1Z39D0TLOoJzR5KdMalERxyPFIqxDMwfTZ4Rjs+q574lOhKGi2eVL08GZZ0A2Xp8A9j3w79ZjQKBgQDLTfQoN6PZTr2XT12COv4166dn6fHt/kZYR4O4axpaxUvdeDeq6INwVy7YU8nTAaZS69wY7XPmNhNH/M4jxjwhuwFurKsoAbn5ZWTuWP/xsbLnSKGw8gOVxINYUQCMVa3t75QuLkqpC/FZqZVLeythSDdSal5Mw2tVplRG7sHkBwKBgQCHrPS64K9rL4nj1HXTi+HN62ZW+SNW6YU0TpmqU9D9PEb+vqS3k/os57YVKF80nPMHbIxXhofympvckHv05P9vqNlfZ3VnVCbdTu8Z4oqbdB53A7gS/Z8/DaEwW/xEWUr0TUsxCrm3WY7Rn2R94cjQ39w9PJ315HJW+naEkkhINQKBgQCy2ByU1H16yN3XoaWszqCaZneZ3h9JMYpIVoD1VqKUf0NBzGOMIYae6NL40pyU1rqt73ZrJ1fxiFhl12qv5c84DP4xkgvu4bXsQtoLIpfk0mGDPE2hDwVAVuMEah2FVknvKfa8uVRMaYkjSx9eizeaGKEyCwhxludxLSSuUZKXOQKBgF0pLwc4mBozQHoIcLgEP1A1lII3XNphGVkJQOlTp48yoCI3a4htrY3yRy6xCzsiSkzFrctb1bZMRhplxCAJ1zQzmyqOQMcovffFpuiuU6fc4f2HnY1+zvGGmcpsz6GYPsng98Gv/xYh5oQ/OPx1D62H71arss80psueY32WIuBt";

    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4AEqxtCp2D3PMj03jE728sunROx6FdhYcsbZrxU7iP600QTVdFKwCJInGLdkeumeLOX7dF8bovrwtijQicTmTpoiUKPtrATW2MaXRnu7s2P+U+MzJyVZ5VuKKlWg8rUp8uh/DhWgUUMYac0THsuCIO9/ZCiyR+wzt/VJI0b6TNoqTQVtXKGywFnWlzvAdwe49CfWKjBaFCCVxb9H+CV0KmR69WXdl7NZCxHMlum/xBVB8PtNcUIOnbdy0Z27zJEZrdfvSqrU7PJm/+mS0xVHw4Smj0M3pWRhh4BZiUDUJg58qO6BpMLFfCwQhCGpptjEv+CtBp1d2g2jfC13T80bnwIDAQAB";

    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    public static String notify_url = "https://www.baidu.com/";

    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问(其实就是支付成功后返回的页面)
    public static String return_url = "https://www.baidu.com/";

    // 签名方式
    public static String sign_type = "RSA2";

    // 字符编码格式
    public static String CHARSET = "utf-8";

    // 支付宝网关，这是沙箱的网关
    public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";

    // 支付宝网关
    public static String log_path = "C:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
